package com.Multithreading.Asynchronization;

public class Main {
    public static final int NACCOUNTS = 100;
    public static final double INITIAL_BALANCE = 1000;
    public static final double MAX_AMOUNT = 1000;
    public static final int DELAY = 100;
    public static void main(String[] args) throws Exception{
        var bank = new Bank(NACCOUNTS, INITIAL_BALANCE);
        for(int i = 0; i < NACCOUNTS; i++) {
            int fromAccount = i;
            var t = new Thread(() -> {
                try{

                    int toAccount = (int) (bank.getSize() * Math.random());
                    double amount = MAX_AMOUNT * Math.random();
                    bank.transform(fromAccount, toAccount, amount);
                    Thread.sleep((int) (DELAY * Math.random()));

                }catch(Exception e) {

                }
            });
            t.start();
        }
    }
}
